﻿
@{
    ViewBag.title = "添加文章";
}

<div class="wrapper wrapper-content ">
    <div class="ibox float-e-margins">
        <div class="ibox-title">
            <h5>@ViewBag.Title</h5>
            <div class="ibox-tools">
            </div>
        </div>
        <div class="ibox-content">
            @using (Html.BeginForm(null, null, FormMethod.Post, new { id = "addArticleForm", @class = "form-horizontal m-t" }))
            {
                <div class="form-group">
                    <label class="col-sm-3 control-label">文章栏目：</label>
                    <div class="col-sm-8">
                        <select class="form-control m-b" name="KId" id="KId">
                            @foreach (var m in ViewBag.ListKinds)
                            {
                                <option value="@m.Id">@m.KindName</option>
                            }
                        </select>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">文章标题：</label>
                    <div class="col-sm-8">
                        <input id="Title" name="Title" maxlength="200" type="text" class="form-control" required aria-required="true" placeholder="填写文章标题">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">副标题：</label>
                    <div class="col-sm-8">
                        <input id="SubTitle" type="text" class="form-control" name="SubTitle" placeholder="文章副标题，非必填" data-title="文章副标题" maxlength="200">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">标题颜色：</label>
                    <div class="col-sm-8">
                        <input id="TitleColor" type="text" class="form-control" name="TitleColor" placeholder="标题颜色，可以填写一个如：#FF0000等" maxlength="20">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">文章来源：</label>
                    <div class="col-sm-8">
                        <input id="Origin" type="text" class="form-control" name="Origin" placeholder="文章来源，不填前台显示：网络" data-title="文章来源，不填前台显示：网络" maxlength="50">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">添加时间：</label>
                    <div class="col-sm-8">
                        <input id="AddTime" type="text" class="form-control" name="AddTime" placeholder="文章来源，不填前台显示：网络" required onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',readOnly:true})" value="@DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">排序：</label>
                    <div class="col-sm-8">
                        <input id="Sequence" type="number" class="form-control" name="Sequence" value="999" maxlength="20" placeholder="越小排得越前" aria-required="true">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">关键字：</label>
                    <div class="col-sm-8">
                        <input id="Keyword" type="text" class="form-control" name="Keyword" value="" maxlength="250" placeholder="优化搜索引擎搜录" aria-required="true">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">描述：</label>
                    <div class="col-sm-8">
                        <input id="Description" type="text" class="form-control" name="Description" value="" maxlength="250" placeholder="优化搜索引擎搜录" aria-required="true">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">TAG：</label>
                    <div class="col-sm-8">
                        <input id="Tags" type="text" class="form-control" name="Tags" value="" maxlength="250" placeholder="TAG关键字，不同关键字请用“,”（英文逗号）隔开" aria-required="true">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">文章点击数量：</label>
                    <div class="col-sm-8">
                        <input id="Hits" type="number" class="form-control" name="Hits" value="0" maxlength="20" placeholder="文章点击数量，仅对文章列表页面有效" aria-required="true">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">跳转链接：</label>
                    <div class="col-sm-8">
                        <input id="LinkURL" type="text" class="form-control" name="LinkURL" value="" maxlength="200" placeholder="填写则点击该类别自动跳转到该地址" aria-required="true">
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-3 control-label">其他属性：</label>
                    <div class="col-sm-8">
                        <label class="checkbox-inline i-checks">
                            <input type="checkbox" value="1" name="IsNew" id="IsNew"> 最新文章
                        </label>
                        <label class="checkbox-inline i-checks">
                            <input type="checkbox" value="1" name="IsRecommend" id="IsRecommend"> 推荐文章
                        </label>
                        <label class="checkbox-inline i-checks">
                            <input type="checkbox" value="1" name="IsHide" id="IsHide"> 隐藏文章
                        </label>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-3 control-label">文章图片：</label>
                    <div class="col-sm-8">
                        <div class="input-group">
                            <input id="Pic" name="Pic" maxlength="250" type="text" class="form-control upload-path" placeholder="请选择或上传一个图片" value="">
                            <span class="input-group-addon my-upload-span upload-img"></span>
                        </div>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-3 control-label">文章内容：</label>
                    <div class="col-sm-8">
                        <textarea id="Content" name="Content" class="form-control" placeholder="可以输入文章内容" required></textarea>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">远程保存图片：</label>
                    <div class="col-sm-8">
                        <label class="checkbox-inline i-checks">
                            <input type="checkbox" value="1" name="autoSaveRemoteImg" checked id="autoSaveRemoteImg"> 自动保存内容中远程图片
                        </label>
                    </div>
                </div>
                <div id="MoreImages">

                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">更多图片(相册)：</label>
                    <div class="col-sm-8">
                        <button class="btn btn-info" type="button" onclick="addImagesrow();"><i class="fa fa-plus"></i> 添加图片 </button>
                    </div>
                </div>

                <div class="hr-line-dashed"></div>
                <div class="form-group">
                    <div class="col-sm-4 col-sm-offset-3">
                        <button class="btn btn-primary" type="submit"><i class="fa fa-save"></i> 提交 </button>
                        <button class="btn btn-default" type="button" onclick="closethisdialog();"><i class="fa fa-close"></i> 取消 </button>
                    </div>
                </div>
            }
        </div>
    </div>


</div>
<script>
    var htmlText = '<div class="form-group" id="nImgRow{0}">';
    htmlText += '<label class="col-sm-3 control-label"><button type="button" class="btn btn-danger btn-sm" onclick="delmyImgRow(\'nImgRow{0}\')"> <i class="fa fa-close"></i> 删除</button></label>';
    htmlText += '<div class="col-sm-8">';
    htmlText += '<div class="input-group">';
    htmlText += '<input id="nImgUrlnImgRow{0}" name="nImgUrl" maxlength="250" type="text" class="form-control upload-path" placeholder="请选择或上传一个图片" value="">';
    htmlText += '<span class="input-group-addon my-upload-span upload-img" id="newimg_{0}"></span>';
    htmlText += '</div></div></div>';

    var items = 1;

    function addImagesrow() {
        var newHtmlTr = htmlText.replace(/\{0\}/g, "new" + items);
        $('#MoreImages').append(newHtmlTr);
        $("#newimg_new" + items).InitUploader({ filesize: "10240", sendurl: "/AdminCP/Upload/DoWebuploaderImage", swf: "/js/webuploader/uploader.swf", filetypes: "gif,jpg,png,bmp,jpeg", notwater: true });
        items += 1;


    }
    function delmyImgRow(id) {
        $("#" + id).remove();
    }
    $(function () {
        //初始化上传控件
        $(".upload-img").InitUploader({ filesize: "10240", sendurl: "/AdminCP/Upload/DoWebuploaderImage", swf: "/js/webuploader/uploader.swf", filetypes: "gif,jpg,png,bmp,jpeg", notwater: true });
        DoPost("addArticleForm");
        //
        $("#TitleColor").colorpicker();
        CKEDITOR.replace('Content');
    })
</script>
@if (!string.IsNullOrEmpty(ViewBag.lastkid))
{
    <script>
        $(function () {
            $("#KId").val(@ViewBag.lastkid);
        })
    </script>
}